#ifndef __BLACK_FUNC_H__
#define __BLACK_FUNC_H__

#include "maths/default.h"
#include "maths/types.h"

#undef MINMAX
#undef max
#undef min

namespace black
{
	
	//__________________________________________________________________________
	bFORCEINLINE int	abs			( int x );
	bFORCEINLINE float	abs			( float x );
	bFORCEINLINE double	abs			( double x );
	bFORCEINLINE __m128	abs			( __m128 x );
	bFORCEINLINE uint	absdiff		( uint a, uint b );
	bFORCEINLINE float	ceil		( float x );
	bFORCEINLINE int	ceilToInt	( float x );
	bFORCEINLINE int	ceilToInt	( double x );
	bFORCEINLINE float	clamp		( float x, float fMin, float fMax );
	bFORCEINLINE void	copySign	( float x, float& res );
	bFORCEINLINE void	copySign	( double x, double& res );
	bFORCEINLINE bool	equals		( float x, float y, float fRelativeTolerance = 0.f, float fAbsoluteTolerance = 0.f );
	bFORCEINLINE float	exp			( float x );
	bFORCEINLINE float	fastInvSqrt ( float x );
	bFORCEINLINE float	floor		( float x );
	bFORCEINLINE int	floorToInt	( float x );
	bFORCEINLINE int	floorToInt	( double x );
	bFORCEINLINE int	toInt		( float x );
	bFORCEINLINE int	toInt		( double x );
	bFORCEINLINE float	toFloat		( int x );
	bFORCEINLINE float	lerp		( float from, float to, float coef );
	bFORCEINLINE float	log			( float x );
	template <typename T>
	bFORCEINLINE T		max			( const T& a, const T& b );
	template <typename T>
	bFORCEINLINE T		max			( const T& a, const T& b, const T& c );
	template <typename T>
	bFORCEINLINE T		min			( const T& a, const T& b );
	template <typename T>
	bFORCEINLINE T		min			( const T& a, const T& b, const T& c );
	bFORCEINLINE int	mod			( int a, const int mult );
	bFORCEINLINE uint	mod			( uint a, const uint mult );
	bFORCEINLINE float	pow			( float x, float y );
	bFORCEINLINE float	pow			( float x, int y );
	bFORCEINLINE float	round		( float x );
	bFORCEINLINE int	roundToInt	( float x );
	bFORCEINLINE int	roundToInt	( double x );
	bFORCEINLINE float	roundPos	( float x );
	bFORCEINLINE float	sqrt		( float x );
	template <typename T>
	bFORCEINLINE void	swap		( T& a, T& b );
	/*bFORCEINLINE void	swap		( uint& a, uint& b );
	bFORCEINLINE void	swap		( float& a, float& b );
	bFORCEINLINE void	swap		( double& a, double& b );*/
	bFORCEINLINE float	truncate	( float x );
	

	// Fast InvSqrt defines
#if !defined( bUSE_FASTINVSQRT_CARMACK_CONSTANT ) && !defined( bUSE_FASTINVSQRT_LOMONT_CONSTANT ) && !defined( bUSE_FASTINVSQRT_CUSTOM_CONSTANT )
 #define bUSE_FASTINVSQRT_CARMACK_CONSTANT
#endif

#if defined( bUSE_FASTINVSQRT_CARMACK_CONSTANT )
 #define bF_FASTINVSQRT_CONSTANT	0x5f3759df
#elif defined( bUSE_FASTINVSQRT_LOMONT_CONSTANT )
 #define bF_FASTINVSQRT_CONSTANT	0x5f375a86
#elif defined( bUSE_FASTINVSQRT_CUSTOM_CONSTANT )
#else
 #error "If you want to use a custom constant, define bUSE_FASTINVSQRT_CUSTOM_CONSTANT"
#endif

}

#include "maths/inl/func.inl"

#endif // __BLACK_FUNC_H__
//---------------------------------------------------------------------------------------
// Copyright (c) 2009 Jounayd Id Salah.
// All rights reserved.
//---------------------------------------------------------------------------------------
